package com.tao.controller;


import com.tao.dto.MyResult;
import com.tao.dto.SuccessResult;
import com.tao.entity.User;
import com.tao.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value="用户controller",tags={"用户"})
@RestController
@CrossOrigin
public class UserController {

    @Autowired
    UserService userService;


    @ApiOperation("用户登录")
    @PostMapping("/user/login")
    public MyResult login(@RequestBody User user){
        return userService.login(user);
    }

    @ApiOperation("用户Token缓存")
    @GetMapping("/get/token")
    public MyResult getToken(String token){
        return new SuccessResult("获取成功",userService.getToken(token));
    }


    @ApiOperation("用户Token缓存")
    @PostMapping("/add")
    public MyResult add(@RequestBody User user){
        return new SuccessResult("操作成功",userService.add(user));
    }

}
